 /**
 * @file tal_binding_table.h
 * @brief Common process - binding table manager
 * @version 1.0.0
 * @date 2021-09-21
 *
 * @copyright Copyright 2018-2021 Tuya Inc. All Rights Reserved.
 *
 */
#ifndef __TAL_BINDING_TABLE_H__
#define __TAL_BINDING_TABLE_H__


#ifdef __cplusplus
    extern "C" {
#endif

#include "tuya_cloud_types.h"
#include "tuya_zigbee_stack.h"



/*
 * zigbee binding table type
 */
typedef enum {
    TAL_UNUSED_BINDING     = 0,     ///< binding table entry is not used
    TAL_UNICAST_BINDING    = 1,     ///< unicast binding, 64bits address is destination MAC
    TAL_MULTICAST_BINDING  = 2,     ///< multicast binding, 16bits address is group id
} TAL_BIND_TYPE_E;

/*
 * zigbee binding table
 */
typedef struct {
    TAL_BIND_TYPE_E  type;          ///< binding type
    UINT8_T          local_ep;      ///< local endpoint
    UINT8_T          remote_ep;     ///< remote endpoint
    UINT16_T         cluster;       ///< cluster id
    // 64bits destination MAC, for unicasts.
    // 16bits multicast group id, for multicasts.
    UINT8_T          address[8];    ///< binding address
} TAL_BINDING_TABLE_T;

/**
 * @brief add binding entry to table
 *
 * @param[in]   entry: binding entry
 * @return  0: success  Other: fail
 */
BOOL_T tal_zg_add_binding(TAL_BINDING_TABLE_T *entry);

/**
 * @brief remove binding entry from table
 *
 * @param[in]   entry: binding entry
 * @return  0: success  Other: fail
 */
BOOL_T tal_zg_remove_binding(TAL_BINDING_TABLE_T *entry);

/**
 * @brief remove clear binding table
 *
 * @param[in]   none
 * @return  0: success  Other: fail
 */
BOOL_T tal_zg_clear_all_binding(VOID_T);


#ifdef __cplusplus
}
#endif

#endif

